

*This code must be run within the main do file. It will not run correctly on its own. 


use "$data/Dry_HI_Comp.dta", replace

	

	local a = " prec below40_dry FND_Max40to45_dry FND_Max45to50_dry FND_Max50to55_dry FND_Max55to60_dry FND_Max60to65_dry FND_Max65to70_dry FND_Max75to80_dry FND_Max80to85_dry FND_Max85to90_dry "
	local d = "prec below40_dry FND_Max40to45_dry FND_Max45to50_dry FND_Max50to55_dry FND_Max55to60_dry FND_Max60to65_dry FND_Max65to70_dry FND_Max75to80_dry FND_Max80to85_dry FND_Max85to90_dry FND_Max90to95_dry"	
	
	label var days95plus_dry "Days \$>95\degree\$F"
	label var days90plus_dry "Days \$>90\degree\$F"

	reghdfe lny_nonag days90plus_dry  `a', absorb(i.fips i.year i.state#c.year) cluster(i.state#i.year)
			est store m1
			
	reghdfe lny_nonag days95plus_dry  `d', absorb(i.fips i.year i.state#c.year) cluster(i.state#i.year)
			est store m3		
			
	preserve
		collapse (sum) days90plus_dry
		
		sum days90plus_dry
		local n1 r(mean)
		local n1 : di %9.0fc `n1'
		file open newfile using "$Table/DB90plus.tex", write replace
		file write newfile "`n1'"
		file close newfile
	restore
	
	preserve
		collapse (sum) days95plus_dry
		
		sum days95plus_dry
		local n2 r(mean)
		local n2 : di %9.0fc `n2'
		file open newfile using "$Table/DB95plus.tex", write replace
		file write newfile "`n2'"
		file close newfile
	restore
		

	local b = " prec below40_wet FND_Max40to45_wet FND_Max45to50_wet FND_Max50to55_wet FND_Max55to60_wet FND_Max60to65_wet FND_Max65to70_wet FND_Max75to80_wet FND_Max80to85_wet FND_Max85to90_wet FND_Max90to93"
	local e = "prec below40_wet FND_Max40to45_wet FND_Max45to50_wet FND_Max50to55_wet FND_Max55to60_wet FND_Max60to65_wet FND_Max65to70_wet FND_Max75to80_wet FND_Max80to85_wet FND_Max85to90_wet FND_Max90to95_wet FND_Max95to100"
		
	label var days93plus_wet "Days \$>93\degree\$F"
	label var days100plus_wet "Days \$>100\degree\$F"
		
	reghdfe lny_nonag days93plus_wet `b', absorb(i.fips i.year i.state#c.year) cluster(i.state#i.year)
			est store m2
			
	reghdfe lny_nonag days100plus_wet `e', absorb(i.fips i.year i.state#c.year) cluster(i.state#i.year)
			est store m4
			
	preserve
		collapse (sum) days93plus_wet
	
		sum days93plus_wet
		local n3 r(mean)
		local n3 : di %9.0fc `n3'
		file open newfile using "$Table/HI93plus.tex", write replace
		file write newfile "`n3'"
		file close newfile
	restore
	
	preserve
		collapse (sum) days100plus_wet
		
		sum days100plus_wet
		local n4 r(mean)
		local n4 : di %9.0fc `n4'
		file open newfile using "$Table/HI100plus.tex", write replace
		file write newfile "`n4'"
		file close newfile
	restore
	
	
	
	esttab m1 m2 m3 m4 using "$Table/HIvDryBulb.tex", replace f ///
		label booktabs b(5) se(5) eqlabels(none) alignment(S S) mtitles("\shortstack{Dry-Bulb}" "\shortstack{Heat Index}" "\shortstack{Dry Bulb}" "\shortstack{Heat Index}" "\shortstack{Heat Index\\5-year avg.}" "\shortstack{Heat Index\\11-year avg.}")  ///
		keep(days*) ///
		star(* 0.10 ** 0.05 *** 0.01) ///
		refcat(, nolabel) ///
		stats(N r2, fmt(%9.0fc 2) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{S}{@}") labels(`"Observations"' `"\(R^{2}\)"' `"County FE"' `"Month FE"' `"Year FE"' `"State $\times\$ Year"' `"State $\times\$ Year$^{2}\$"' `"State $\times\$ Year$^{3}\$"'))

	clear
